package com.atguigu.spzx.manager.service.product.impl;

import com.atguigu.spzx.common.log.anno.SysLog;
import com.atguigu.spzx.common.log.enu.OperatorType;
import com.atguigu.spzx.manager.mapper.BrandMapper;
import com.atguigu.spzx.manager.service.product.BrandService;
import com.atguigu.spzx.model.entity.product.Brand;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author Mahone
 */
@Service
public class BrandServiceImpl implements BrandService {

    @Autowired
    private BrandMapper brandMapper;

    @Transactional
    @SysLog(title = "查询商标",operatorType = OperatorType.MANAGE,businessType = 0)
    @Override
    public List<Brand> findAll() {
        List<Brand> brandList = brandMapper.selectAllBrand();
        return brandList;
    }

    @Override
    public PageInfo<Brand> getBrandPageList(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Brand> brandList = brandMapper.selectAllBrand();
        return new PageInfo<>(brandList);
    }

    @Override
    public void insertBrand(Brand brand) {
        brandMapper.insertBrand(brand);
    }

    @Override
    public void updateBrand(Brand brand) {
        brandMapper.updateBrand(brand);
    }

    @Override
    public void deleteBrandById(Long id) {
        brandMapper.deleteBrandById(id);
    }
}
